const {
    defineConfig,
} = require("@vue/cli-service");
const path = require("path");

function resolve(dir) {
    /**
     * __dirname：当前文件夹所在的绝对路径
     */
    return path.join(__dirname, dir);
}

module.exports = defineConfig({
    transpileDependencies: true,
    // 使打出来的包可以被部署在任意路径
    publicPath: process.env.NODE_ENV === "production" ? "./" : "/",
    // 每次保存，检查错误，不能编译通过
    lintOnSave: "error",
    chainWebpack: (config) => {
        config.resolve.alias
            .set("@", resolve("./src"))
            .set("@utils", resolve("./src/utils"))
            .set("@components", resolve("./src/components"))
            .set("@api", resolve("./src/api"))
            .set("@icon", resolve("./src/assets/icon"))
            .set("@pic", resolve("./src/assets/picture"))
            .set("@views", resolve("./src/views"))
            .set("@styles", resolve("./src/assets/styles"));
    },
});